/*using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Collections.Concurrent;

namespace rudp
{
	public class UdpSocketReceiver
	{
		public UdpSocketReceiver ( )
		{
		}

		public void Read (CommunicationState state)
		{
			state.Buffer = new byte[1400];
			IPEndPoint endPoint = new IPEndPoint (IPAddress.Any, 0);

			IAsyncResult result = state.Socket.BeginReceiveFrom (state.Buffer, 0, 1400, SocketFlags.None, 
																 ref state.RemoteHost, 
			                                                     new AsyncCallback (this.OnMessagePacketReceived), state);			
		}

		public void OnMessagePacketReceived (IAsyncResult result)
		{
			EndPoint ipEndPoint = new IPEndPoint (IPAddress.Any, 0);

			CommunicationState state = (CommunicationState)result.AsyncState;
			int bytesReceived = state.Socket.EndReceiveFrom (result, ref ipEndPoint);

			MessagePacket packet = new MessagePacket ();
			packet.FromByteArray (state.Buffer);	

			state.Packets.Add (packet);

			if ((packet.Flags & MessageFlags.ReceiptRequest) == MessageFlags.ReceiptRequest) {
				this.OnReceiptRequestReceived (state);
			} else if( ( packet.Flags & MessageFlags.Data ) == MessageFlags.Data ) {
				this.Read( state );
			}
		}
	}
}

*/